package com.roper.easyexcel.single;

/**
 * Description:
 * Date:      2022/2/13 21:08
 * author:    LPH
 * version:   V1.0
 */
public class Singleton {
    public static void main(String[] args) {
        SingletonE instance = SingletonE.getInstance();
    }
}

class SingletonE {
    private SingletonE() {
    }

    private static SingletonE singletonE = new SingletonE();

    public static SingletonE getInstance() {
        return singletonE;
    }
}

class SingletonL {
    private SingletonL() {

    }

    private static SingletonL singletonL = null;

    public static SingletonL getInstanceYh() {
        if(singletonL == null) {
            synchronized (SingletonL.class) {
                if (singletonL == null) {
                    singletonL = new SingletonL();
                }
            }
        }
        return singletonL;
    }
}

class SingletonN {
    private SingletonN(){};

    private static class SingleHander {
        private static SingletonN singletonN = new SingletonN();
    }

    public static SingletonN getInstance() {
        return SingleHander.singletonN;
    }
}
